<?php
$page->BodyId = 'smiley';
$page->BodyClass = '';
$page->Section = '';

$page->SetWrapperFile('_wrapper');

?>

<!-- div class="cms" -->
<? if ( $page->Message ): ?>
	<p>
		<?=$page->Message?>
	</p>
<? endif ?>

<? if ( $page->Error ): ?>
	<p class="error">
		<?=$page->Error?>
	</p>
<? endif ?>

<? if ( !$page->Smiley ): ?>
	<p>Smiley not found</p>
<? else: ?>
	<div class="smiley <?=$page->Smiley->IsFavorite()?'favorite':''?>">
		<h3>
			<a href="<?=$page->Smiley->Href()?>"><img src="<?=$page->Smiley->Url()?>" width="<?=$page->Smiley->Width()?>" height="<?=$page->Smiley->Height()?>" /></a>
		</h3>
		<? if ( $page->Smiley->Title() ): ?>
			<h4><?=$page->Smiley->Title()?></h4>
		<? endif ?>
	
		<p class="code" title="Click to hilight and copy">
			<p class="html">
				<input type="text" value="<?=htmlentities('<img src="' . $page->Smiley->Url() . '" />')?>" />
				<? /*<a href="<?=$page->SetCodeBbUrl?>">(ubb)</a>*/ ?>
			</p>
			<p class="ubb">
				<input type="text" value="[img]<?=$page->Smiley->Url()?>[/img]" />
				<? /*<a href="<?=$page->SetCodeHtmlUrl?>">(html)</a>*/ ?>
			</p>
		</p>
	
		<? if ( $page->ArchiveDisplay != 'user' && $page->Smiley->User() && $page->Smiley->User()->Dname() && $page->Smiley->User()->Url() ) { ?>
			<p class="user">
				By: <a href="<?=$page->Smiley->User()->Url()?>"><?=$page->Smiley->User()->Dname()?></a>
			</p>
		<? } ?>
	
		<div class="favorites">
			<ul>
				<li class="add_favorite"><a href="<?=$page->Smiley->AddFavoriteUrl()?>">Add To Favorites</a></li>
				<li class="remove_favorite"><a href="<?=$page->Smiley->RemoveFavoriteUrl()?>">Remove From Favorites</a></li>
			</ul>
		</div>
	
		<div class="tags">
			<h4>Tags:</h4>
			<ul>
				<? foreach ( $page->Smiley->Tags()->Values as $tag ): ?> 
					<li class="tag <? /*=(($tag->UserTagged())?'voted':'') */?>">
						<span class="vote <?=$tag->Voted()?'voted':''?>">
							<a href="<?=$tag->UpUrl()?>" class="add_vote" title="Agree with this tagging">+</a>
							<a href="<?=$tag->DownUrl()?>" class="remove_vote" title="Remove your vote">-</a>
						</span>
						<a href="<?=$tag->Url()?>"><?=$tag->Name()?> <span class="count">(<?=$tag->Count()?>)</span></a>
					</li>
				<? endforeach ?>
			</ul>
		</div>
	
		<form action="<?=$page->Url?>" id="add_tags" method="post">
			<fieldset>
				<p class="input text">
					<label for="user_tags">Help others find this smiley, add your own tags:</label>
					<input type="text" name="tags" id="user_tags" value="<?=$page->UserTags?>" />
					<span class="info">(separate each tag with a comma, e.g. happy, sneaky, yellow, square)</span>
				</p>
				<p class="input submit">
					<span class="jelly"><span class="start"></span><span class="bg"></span><span class="end"></span>
						<input type="submit" value="Add" class="text" />
					</span>
				</p>
			</fieldset>
		</form>
	
		<div id="smiley_posts">
			<h4>Posts:</h4>
			<? Site::RenderView('modules/_view_posts', array('entity' => $page->Smiley)) ?>
			<p id="create_post">
				<a href="<?=$page->Smiley->CreatePostUrl()?>">Comment on this smiley :)</a>
			</p>
		</div>
	</div>
<? endif ?>
<!-- /div -->